import Vue from "vue"
import Vuex from "vuex"
import userStore from "./modules/user"
import tagsView from "./modules/tagsView"
import vuexPersistedState from "vuex-persistedstate"
import router from "../router/index"
import breadcrumb from "./modules/breadcrumb"

//使用插件的方式
Vue.use(Vuex);

const store = new Vuex.Store({
  modules: {
    userStore,
    tagsView,
    breadcrumb
  },
  plugins: [vuexPersistedState({
    //存储位置
    storage: window.sessionStorage,
    reducer(data) {
      return {
        //持久化数据
        userStore: data.userStore,
        tagsView: data.tagsView,
        breadcrumb: breadcrumb
      }
    }
  })]
})

//导出对象
export default store;
